﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using AppSocketModel; 
using AppSocketService.Location;
using BCGPSRESTful.WebApiConfig;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace BCGPSRESTful.Controllers.Page.Location
{
    /// <summary>
    /// 车辆位置信息
    /// </summary>
    [ApiExplorerSettings(GroupName = "CompanyPage")]
    [Route("api/[controller]")]
    [ApiController]
    public class LocationController : PageBaseController
    {
        private readonly ILocationService locationService;

        #region 构造函数 
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="locationService"></param>
        public LocationController(ILocationService locationService)
        {
           this. locationService = locationService;
        }
        #endregion

        #region 获取 Redis 车辆位置
        /// <summary>
        /// 获取 Redis 设备位置
        /// </summary>
        /// <param name="imei"></param>
        /// <param name="gps_map_type">地图种类</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType (typeof(LocationDto),200)]
        public ActionResult<LocationDto> GetLocation(string imei,GpsMapType? gps_map_type = GpsMapType.GDMAP )
        {
            return locationService.GetLocation(imei,gps_map_type.Value);
        }
        #endregion

        #region 获取账户下车辆位置 不包括子账户
        /// <summary>
        /// 获取账户下车辆位置 不包括子账户
        /// </summary>
        /// <param name="account_id">账户Id</param>
        /// <param name="gps_map_type">地图种类</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(List<LocationDto>), 200)]
        public ActionResult<List<LocationDto>> GetLocationList(string account_id, GpsMapType? gps_map_type = GpsMapType.GDMAP)
        {
            return locationService.GetList(account_id, gps_map_type.Value);
        }
        #endregion

        #region 获取账户下车辆位置 包括子账户
        /// <summary>
        /// 获取账户下车辆位置 包括子账户
        /// </summary>
        /// <param name="account_id">账户Id</param>
        /// <param name="gps_map_type">地图种类</param>
        /// <returns></returns>
        [HttpGet("[action]")]
        [ProducesResponseType(typeof(List<LocationDto>), 200)]
        public ActionResult<List<LocationDto>> GetLocationListAll(string account_id, GpsMapType? gps_map_type = GpsMapType.GDMAP)
        {
            return locationService.GetListAll(account_id, gps_map_type.Value);
        }
        #endregion

         
    }
}